#include <REGX52.H>
sbit I2C_SCL=P2^1;
sbit I2C_SDA=P2^0;
void I2C_START()
{
	I2C_SDA=1;
	I2C_SCL=1;
	I2C_SDA=0;
	I2C_SCL=0;
}
void I2C_STOP()
{
	I2C_SDA=0;
	I2C_SCL=1;
	I2C_SDA=1;
	
}
void I2C_SENDBITY(unsigned char bity)
{
	unsigned char i=0;
	for(i=0;i<8;i++)
	{
		
		I2C_SDA=bity&(0x80>>i);
		I2C_SCL=1;
		I2C_SCL=0;
	}
}
unsigned char I2C_RECIVEBITY()
{
	unsigned char i=0,bity=0x00;
	I2C_SDA=1;
	for(i=0;i<8;i++)
	{
		I2C_SCL=1;
		if(I2C_SDA){bity|=(0x80>>i);}
		I2C_SCL=0;
	}
	return bity;
}
void sendack(unsigned char sendbit)
{
	I2C_SDA=sendbit;
	I2C_SCL=1;
	I2C_SCL=0;
}
unsigned char reciveack()
{
	unsigned char recivebit=0;
	I2C_SDA=1;
	I2C_SCL=1;
	recivebit=I2C_SDA;
	I2C_SCL=0;
	return recivebit;
}